#ifndef KEYBASEDLISTMODEL_H
#define KEYBASEDLISTMODEL_H

#include <QAbstractListModel>
#include <QStringList>

class KeyBasedListModel : public QAbstractListModel
{
    Q_OBJECT
public:
    explicit KeyBasedListModel(QObject *parent = 0);

    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
    virtual int rowCount (const QModelIndex &parent = QModelIndex()) const;

    QStringList getOrderedKeys() const;

protected slots:
    void addKey(const QString& key);
    void updateKey(const QString& oldKey, const QString& newKey);
    void removeKey(const QString& key);
    void clearKeys();

protected:
    QString keyFromIndex(const QModelIndex& index) const;

    virtual QVariant getDataForKey(const QString& key, int column, int role) const = 0;
    
private:
     QStringList list;
};

#endif // KEYBASEDLISTMODEL_H
